<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title> - 数据表格</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <!-- Data Tables -->
    <link href="css/dataTables.bootstrap.css" rel="stylesheet">

    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <link href="css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <script src="js/jquery-1.12.4.min.js"></script>
</head>

<script>
    /**
     * 全部商品
     */

    $(document).ready(function () {
        getAllGoods(0, 5);
    })

    function getAllGoods(page, size) {
        $.ajax({
            url: "getAllGoods",
            data: {page: page, size: size},
            dataType: "json",
            type: "GET",
            success: function (msg) {
                //alert(msg);
                var str = '';
                for (var i = 0; i < msg.data.length; i++) {
                    str = str + '<tr class="gradeX"><td>'+msg.data[i].goods_id+'</td>'+
                    '<td>'+msg.data[i].goods_name+'</td>'+
                    '<td>'+msg.data[i].goods_price+'</td>'+
                    '<td>'+msg.data[i].goods_info+'</td>'+
                    '<td>'+msg.data[i].goods_unit+'</td>'+
                    '<td>'+msg.data[i].goods_time+'</td>'+
                    '<td>'+msg.data[i].goods_number+'</td>'+
                    '<td style="text-align: center;">'+
                        '<a class="btn btn-white btn-bitbucket" title="编辑" href="javascript:edit('+msg.data[i].goods_id+')">'+
                        '<i class="fa fa-pencil-square-o" aria-hidden="true"></i>'+
                        '</a>'+
                        '<input type="hidden" value="32"/>'+
                        '<a class="btn btn-white btn-bitbucket delete" title="删除"  href="javascript:;">'+
                        '<i class="fa fa-trash-o" aria-hidden="true"></i>'+
                        '</a> </td> </tr>';
                }
                $("#goods").html(str);
                str2 = '<a href="javascript:getAllGoods(' + (page - 1) + ', 5)">' +
                    '上一页</a>&nbsp;&nbsp' +
                    ' <span  id="mya"></span >' +
                    '<a href="javascript:getAllGoods(' + (page + 1) + ', 5)">下一页</a>';
                $("#index").html(str2);
                var myindex = msg.maxPage;
                if (myindex != '') {
                    myindex = parseInt(myindex);
                    var str3 = '';
                    for (var i = 0; i < myindex; i++) {
                        str3 = str3 + '<a href="javascript:getAllGoods(' + (i + 1) + ', 5)" class="active">' + (i + 1) + '</a>&nbsp;&nbsp;&nbsp';
                    }
                    $("#mya").html(str3);


                }


            }
        })

    }
</script>
<script>
    function edit(id) {
        location.href="getGoodsById?id="+id;
    }
</script>
<SCRIPT>
    function outoExcel() {
        location.href="exportExcel";
    }
</SCRIPT>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>商品列表</h5>
                    <div class="ibox-tools">
                        <!-- <a href="admin_user_edit.action">
                             <button type="button" class="btn btn-default btn-xs">添加</button>
                        </a> -->
                    </div>
                </div>
                <div class="ibox-tools" style="margin-top: 0px;float: left;">
                    <form action="admin_huiyuanmeirishouzhilog_list.action" method="post" role="form" class="form-inline">
                        <input type="hidden" name="" value="">
                        <div class="form-group" style="padding-right: 5px;padding-left: 5px;">
                            <div class="col-sm-10" style="margin-bottom: 5px; margin-top:5px;padding-right: 0px;padding-left: 0px;">
                                <input name="huiyuanmeirishouzhilog.huiyuanusername" placeholder="商品名称" style="height: 29px;width: 120px;" class="form-control">
                            </div>
                        </div>
                        <div class="form-group" style="padding-right: 5px;padding-left: 5px;">
                            <div class="col-sm-10" style="margin-bottom: 5px; margin-top:5px;padding-right: 0px;padding-left: 0px;">
                                <input name="huiyuanmeirishouzhilog.huiyuanxingming" placeholder="商品类型" style="height: 29px;width: 120px;padding: 6px 5px;" class="form-control">
                            </div>
                        </div>
                        <div class="checkbox m-l m-r-xs" style="margin-left: 0px; margin-top:5px;">
                            <button class="btn btn-white" type="submit">查询</button>
                        </div>
                        <div class="checkbox m-l m-r-xs" style="margin-left: 0px; margin-top:5px;">
                            <button class="btn btn-white" type="button" onclick="add()">添加</button>
                        </div>
                        <div class="checkbox m-l m-r-xs" style="margin-left: 0px; margin-top:5px;">
                            <button class="btn btn-white" type="button" onclick="outoExcel()">导出文件</button>
                        </div>
                        <script>
                            function add() {
                                location.href="getAllType";
                            }
                        </script>
                    </form>
                </div>
                <div class="ibox-content">
                    <table class="table table-striped table-bordered table-hover dataTables-example">
                        <thead>
                        <tr>
                            <th>商品id</th>
                            <th>商品名称</th>
                            <th>商品价格</th>
                            <th>商品描述</th>
                            <th>商品单位</th>
                            <th>上架时间</th>
                            <th>商品库存</th>
                            <th style="text-align: center;">操作</th>
                        </tr>
                        </thead>
                        <tbody id="goods">

                        </tbody>

                    </table>
                    <div id="index" align="center"></div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>

<script src="js/plugins/jeditable/jquery.jeditable.js"></script>

<!-- Data Tables -->
<script src="js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="js/plugins/dataTables/dataTables.bootstrap.js"></script>

<!-- 自定义js -->
<script src="js/content.js?v=1.0.0"></script>

<script src="js/plugins/sweetalert/sweetalert.min.js"></script>
<!-- Page-Level Scripts -->
<#--<script>-->
    <#--$(document).ready(function () {-->
        <#--$(".delete").click(function () {-->
            <#--var id=$(this).prev().val();-->
            <#--swal({-->
                    <#--title: "您确定要删除这条信息吗",-->
                    <#--text: "删除后将无法恢复，请谨慎操作！",-->
                    <#--type: "warning",-->
                    <#--showCancelButton: true,-->
                    <#--confirmButtonColor: "#DD6B55",-->
                    <#--confirmButtonText: "是的，我要删除！",-->
                    <#--cancelButtonText: "让我再考虑一下…",-->
                    <#--closeOnConfirm: false,-->
                    <#--closeOnCancel: false-->
                <#--},-->
                <#--function (isConfirm) {-->
                    <#--if (isConfirm) {-->
                        <#--window.location.href="admin_user_del.action?user.id="+id;-->
                        <#--swal("删除成功！", "您已经永久删除了这条信息。", "success");-->
                    <#--} else {-->
                        <#--swal("已取消", "您取消了删除操作！", "error");-->
                    <#--}-->
                <#--});-->
        <#--});-->

        <#--$('.dataTables-example').dataTable();-->

        <#--/* Init DataTables */-->
        <#--var oTable = $('#editable').dataTable();-->

        <#--/* Apply the jEditable handlers to the table */-->
        <#--oTable.$('td').editable('../example_ajax.php', {-->
            <#--"callback": function (sValue, y) {-->
                <#--var aPos = oTable.fnGetPosition(this);-->
                <#--oTable.fnUpdate(sValue, aPos[0], aPos[1]);-->
            <#--},-->
            <#--"submitdata": function (value, settings) {-->
                <#--return {-->
                    <#--"row_id": this.parentNode.getAttribute('id'),-->
                    <#--"column": oTable.fnGetPosition(this)[2]-->
                <#--};-->
            <#--},-->

            <#--"width": "90%",-->
            <#--"height": "100%"-->
        <#--});-->


    <#--});-->

    <#--function fnClickAddRow() {-->
        <#--$('#editable').dataTable().fnAddData([-->
            <#--"Custom row",-->
            <#--"New row",-->
            <#--"New row",-->
            <#--"New row",-->
            <#--"New row"]);-->

    <#--}-->
<#--</script>-->
</body>

</html>
